package com.example.androidgeneric;

import java.util.ArrayList;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

public class StudentList extends GenericsListView<Student> implements OnItemClickListener {

	@Override
	public ArrayList<Student> setData() {
		
		ArrayList<Student> list = new ArrayList<Student>();
		
		Student data = new Student();
		data.setName("kim yong hee");
		data.setAge("29");
		data.setStudentNumber("20051233");
		data.setGeneration("Universty 4 Generation");
		
		for (int i = 0; i < 20; i++) {
			list.add(data);
		}
		
		return list;
	}
	
	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		
		getListView().setOnItemClickListener(this);
	}

	@Override
	@SuppressWarnings("unchecked")
	public void onItemClick(AdapterView<?> adapterView, View itemView, int position, long id) {
		Toast.makeText(getActivity(), ((ArrayAdapter<Student>) getListAdapter()).getItem(position).getStudentNumber(), Toast.LENGTH_SHORT).show();
	}
}
